#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/ipc.h>
#include <inttypes.h>
#include <time.h>
#include <ptcParse.h>
#include <cstring.h>
#include <cCheck.h>
// common type operate struct

int logcFunc(int lev, const char *lfile, int lline, const char *fmt, ...)
{
    if (lev > param_LogLevel)
    {
        return 0;
    }
    static const char *logstr[] = {
        "fat",
        "err",
        "wrn",
        "inf",
        "dbg",
        "trc"};
    struct timeval tnow;
    struct tm *tmnow;
    gettimeofday(&tnow, NULL);
    tmnow = localtime(&tnow.tv_sec);
    char tmpPrtStr[2048] = {0};
    const char *tmpFileName;
    (tmpFileName = strrchr(lfile, '/')) ? tmpFileName++ : (tmpFileName = lfile);
    int tmplen = snprintf(tmpPrtStr, sizeof(tmpPrtStr), "[%d-%02d-%02d %02d:%02d:%02d.%03d]%s[%s,%d]",
                          tmnow->tm_year + 1900, tmnow->tm_mon + 1, tmnow->tm_mday, tmnow->tm_hour, tmnow->tm_min, tmnow->tm_sec,
                          tnow.tv_usec / 1000 % 1000, logstr[lev], tmpFileName, lline);
    va_list args;
    va_start(args, fmt);
    tmplen += vsnprintf(tmpPrtStr + tmplen, sizeof(tmpPrtStr) - tmplen, fmt, args);
    va_end(args);
    printf("%s\n", tmpPrtStr);
    return tmplen;
}
void chkfunc();
int main(int argsize, const char **args)
{
    myLogDbg("%d,%d", 1, (uint64_t)2);
    myLogDbg("1234567890123456789012345678901234567890");
    // logdebug("%d,%d", 1, (uint64_t)2);
    chkfunc();
    return 0;
}